/*
 * @Description: 原型链+借用构造函数
 * @Author: zzj
 * @Date: 2021-09-07 12:21:09
 * @LastEditors: zzj
 * @LastEditTime: 2021-09-14 15:57:01
 */

//原型链+借用构造函数
function Animal(name,age){
    this.name = name;
    this.age = age;
}
Animal.prototype.sayName = function(){
    console.log(this.name);
}
function Dog(name,age,color){
    Animal.call(this,name,age);
    this.color = color;
}
Dog.prototype = new Animal();
Dog.prototype.constructor = Dog; // 将构造函数设置回来

Dog.prototype.sayColor = function(){
    console.log(this.color);
}
var d1 = new Dog("xiaobai",2,"white");
d1.sayName();
d1.sayColor();